﻿#pragma once

#include "BaseGlobal.h"
#include <QSortFilterProxyModel>

class QRecordTreeModel;
//==================================================================================================
//	设备分组类型树模型
class BASE_EXPORT QRecordFilterModel : public QSortFilterProxyModel
{
	Q_OBJECT

public:
	//----------------------------------------------------------------------------------------------
	QRecordFilterModel( QObject * parent = NULL );
	~QRecordFilterModel( );

	//----------------------------------------------------------------------------------------------
	QRecordTreeModel * dataModel( void ) const;
	void dataModel( QRecordTreeModel * model );

	//----------------------------------------------------------------------------------------------
	bool showGroup( void ) const;
	void showGroup( bool value );

	//----------------------------------------------------------------------------------------------
	bool showAll( void ) const;
	void showAll( bool value );

	//----------------------------------------------------------------------------------------------
	void setFields(short ID, short Pid, short Alias, short GroupFiled, short DataField);
	void setRootNode(int groupNode, int noGroupNode = 0);

	//----------------------------------------------------------------------------------------------
	QModelIndex getModelIndex( const QVariant & cid );
	QModelIndex getGroupModel(int row);
	QModelIndex getGroupModel( );
	
protected:
	//----------------------------------------------------------------------------------------------
	virtual bool filterAcceptsRow( int row , const QModelIndex & parent) const;
	virtual Qt::ItemFlags flags(const QModelIndex & index) const;

	void switchModel( void );

protected:
	//----------------------------------------------------------------------------------------------
	short GroupField , DataField, Alias, ID, PID;
	bool ShowGroup , ShowAll ;
	int groupNode, noGroupNode;

};
